class A {
  constructor() {
    this.firstName = "jam";
    this.lastName = "green";
    this.age = 12;
  }
  toJSON() {
    return { name: this.firstName + "." + this.lastName, age: this.age };
  }
  get fullInfo() {
    return `${this.name} - ${this.age}`;
  }
}
const a = new A();
const o = { a, id: 123 };
console.log(JSON.stringify(o)); // {"a":{"name":"jam.green","age":12},"id":123}
